﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shipei : MonoBehaviour
{
    float devWidth = 7.2f;

	// Use this for initialization
	void Start ()
    {
        float screenHeight = Screen.height;
        Debug.Log("screenHeight = " + screenHeight + " width = " + Screen.width);
        //摄像机的尺寸
        float orthographicSize = this.GetComponent<Camera>().orthographicSize;
        Debug.Log("orthographicSize = " + orthographicSize);
        //宽高比
        float aspectRatio = Screen.width * 1.0f / Screen.height;
        //摄像机的单位宽度
        float cameraWidth = orthographicSize * 2 * aspectRatio;

        Debug.Log("aspectRatio = " + aspectRatio + "cameraWidth = " + cameraWidth);
        //如果设备的宽度大于摄像机的宽度的时候  调整摄像机的orthographicSize
        if (cameraWidth < devWidth)
        {
            orthographicSize = devWidth / (2 * aspectRatio);
            Debug.Log("new orthographicSize = " + orthographicSize);
            this.GetComponent<Camera>().orthographicSize = orthographicSize;
        }
    }
}
